package com.server.game.logic.system;


import com.server.orm.XDBManager;
import com.server.util.ConfPropertiesUtil;
import xbean.ServerId;
import xdb.Procedure;
import xtable.Localids;

import java.util.Objects;

/**
 * 更新本地合服服务器ids
 */
public class PInitLocalId extends Procedure {

    @Override
    protected boolean process() throws Exception {
        //
        int serverId = ConfPropertiesUtil.getInstance()._SERVER_ID;
        // 添加合服过的ids
        ServerId localIds = xtable.Localids.get(XDBManager.XDB_LOCAL_ID_KEY);
        if (Objects.isNull(localIds)) {
            localIds = xbean.Pod.newServerId();
            localIds.getSid().add(serverId);
            Localids.insert(XDBManager.XDB_LOCAL_ID_KEY, localIds);
        }
        xdb.Xdb.getInstance().initLocalIds(localIds.getSid());
        return true;
    }
}
